<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="shortcut icon" href="http://yangwenxue.oschina.io/images/favicon.ico">
		<link rel="stylesheet" href="http://yangwenxue.oschina.io/css/boostrap/bootstrap-3.2.0.min.css">
		<link rel="stylesheet" href="http://yangwenxue.oschina.io/css/boostrap/star-rating.css" />
		<link rel="stylesheet" href="http://yangwenxue.oschina.io/css/boostrap/bootstrap-datetimepicker.min.css" />
	</head>

	<body>
		<div class="py-5">
			<div class="container">
				<div class="row">
					<div class="col-md-12">
						<ul class="breadcrumb" style="margin-bottom: 0px; margin-top: 0px;">
							<li class="breadcrumb-item">
								<a href="company_index.html">面试资源</a>
							</li>
							<li class="breadcrumb-item">
								<a href="company_list.html">公司列表</a>
							</li>
							<li class="breadcrumb-item active">公司详情</li>
						</ul>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12 text-center">
						<img src="http://yangwenxue.oschina.io/images/favicon.ico" id="userImageUrl" class="rounded-circle img-fluid mx-auto d-block"> </div>
				</div>
			</div>
		</div>
		<div class="py-5">
			<div class="container">
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-center">公司名称：<span id="companyName">Yoko</span></li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-center">学科：<span id="recruitType">java</span></li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-center">公司地址：<span id="companyAddress">北京市昌平区北七家修正大厦</span></li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-center">联系人：<span id="employeeName">Yoko</span></li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-center">联系人电话：<span id="companyPhone">185-1516-1858</span></li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-center">是否是培训结构：<span id="recruitState1" class="text-danger">否</span> </li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-center">是否要求学历：<span id="isEdu" class="text-danger">否<br></span> </li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-center">是否已停止招聘：<span id="recruitState2" class="text-danger">否<br></span> </li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-left">学员反馈：
							<ul id="comment-list">
								<li>
									<input readonly="readonly" value="1" type="number" class="rating" min=0 max=5 step=1 data-size="sm"> 这家公司还不错，不是培训机构，面试题
								</li>
							</ul>
						</li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-center"><span id="interviewHistory">暂时没有学员去过这家公司</span>，好了，就去这家了，选择时间：<input type="text" id="datetimepicker" readonly><button type="button" class="btn btn-primary" onclick="goWork()">提交</button>
						</li>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<li class="list-group-item text-left">不招人了？培训机构？添加反馈！！ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
							<br>
							<form class="" method="post" id="add-comment">
								是否是培训机构：
								<input name="recruitState2" value="2" type="radio">是
								<input name="recruitState2" value="0" checked="checked" type="radio">否
								<br> 是否已停止招聘：
								<input name="recruitState1" value="1" type="radio">是
								<input name="recruitState1" value="0" checked="checked" type="radio">否
								<br /> 打分：
								<input id="star" name="star" value="4" type="number" class="rating" min=0 max=5 step=1 data-size="sm">
								<input type="hidden" id="foreignKeyId" name="foreignKeyId" />
								<input type="hidden" id="recruitId" name="recruitId" />
								<textarea class="form-control" name="comment" rows="7" placeholder="评论"></textarea>
								<button type="button" class="btn btn-primary" id="btn-add-comment" onclick="addcommentList()">评论</button>
							</form>
						</li>
					</div>
				</div>
			</div>
		</div>
		<div class="py-5">
			<div class="container">
				<div class="row">
					<div class="col-md-12 mt-3 text-center">
						<p>© 2017-Yokol.top版权所有-<a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=17061202" target="_blank">&nbsp;京ICP备17061202号 </a></p>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="http://yangwenxue.oschina.io/js/jquery/jquery.min.js"></script>
		<script type="text/javascript" src="http://yangwenxue.oschina.io/js/boostrap/star-rating.js"></script>
		<script type="text/javascript" src="http://yangwenxue.oschina.io/js/boostrap/bootstrap-datetimepicker.min.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<script>
			$(function() {
				$.fn.datetimepicker.dates['zh'] = {
					days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
					daysShort: ["日", "一", "二", "三", "四", "五", "六", "日"],
					daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
					months: ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
					monthsShort: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
					meridiem: ["上午", "下午"],
					today: "今天"
				};
				$('#datetimepicker').datetimepicker({
					bootcssVer: 3, // 左右月份跳转
					language: 'zh', // 中文
					format: 'yyyy-MM-dd', // 显示的字符样式
					todayBtn: true, // 今天的按钮
					autoclose: true, // 自动关闭 
					todayHighlight: true, // 今天的样式高亮显示
					forceParse: true, // 强制格式化时间
					startDate: new Date(), //开始时间
					minView: 2 //显示到日
				});
				var id = getUrlParam("id");
				// 获取招聘信息ID
				$("#recruitId").val(id);
				// 初始化公司信息
				initCompany(id);
			});

			// 初始化公司信息
			function initCompany(id) {
				$.ajax({
					url: resPath_work + "company/getCompanyById",
					type: "post",
					data: {
						id: id
					},
					dataType: 'json',
					success: function(data) {
						// 初始化公司信息
						$("#companyAddress").html(data.data.companyAddress);
						$("#companyName").html(data.data.companyName);
						$("#companyPhone").html(data.data.companyPhone);
						$("#employeeName").html(data.data.employeeName);
						$("#isEdu").html(data.data.isEdu == 0 ? '否' : '是');
						$("#recruitState1").html(data.data.recruitState == 2 ? '是' : '否');
						$("#recruitState2").html(data.data.recruitState == 1 ? '是' : '否');
						$("#foreignKeyId").val(data.data.id);
						if(data.data.counts != undefined && data.data.counts > 0) {
							$("#interviewHistory").html("最近三天已有" + data.data.counts + "名学员去过这家公司");
						} else {
							$("#interviewHistory").html("暂时没有学员去过这家公司");
						}

						// 根据公司ID获取评论列表
						getcommentList(data.data.id);
					},
					error: function() {
						alert("获取公司列表失败");
					}
				});
			};

			// 根据公司ID获取评论列表
			function getcommentList(companyId) {
				$.ajax({
					url: resPath_work + "comment/getCommentList",
					type: "post",
					data: {
						companyId: companyId
					},
					dataType: 'json',
					success: function(data) {
						// 首先清空评论列表
						$("#comment-list").html("");
						var resList = data.data;
						var htmlCode = "";
						for(var i = 0; i < resList.length; i++) {
							var code = resList[i];
							htmlCode += '<li>' +
								'<input readonly="readonly" value="' + code.star + '" type="number" class="rating" min=0 max=5 step=1 data-size="sm">' + code.comment +
								'</li>';
						}
						// 追加评论列表
						$("#comment-list").append(htmlCode);
						// 初始化评分样式
						$(".rating").rating();
					},
					error: function() {
						alert("获取公司列表失败");
					}
				});
			};

			// 添加评论
			function addcommentList() {
				$.ajax({
					url: resPath_work + "comment/addComment",
					type: "post",
					data: $("#add-comment").serializeJson(),
					dataType: 'json',
					success: function(data) {
						// 添加成功为提高用户体验度把新添加的直接通过JS添加在前端页面
						var htmlCode = '<li>' +
							'<input readonly="readonly" value="' + $("#star").val() + '" type="number" class="rating" min=0 max=5 step=1 data-size="sm">' + $("textarea[name=comment]").val() +
							'</li>';
						$("#comment-list").append(htmlCode);
						$("textarea[name=comment]").val("");
						$(".rating").rating();
					},
					error: function() {
						alert("评论失败");
					}
				});
			};

			// 添加
			function goWork() {
				$.ajax({
					url: resPath_work + "interviewHistory/addInterview",
					type: "post",
					data: {
						companyId: $("#foreignKeyId").val(),
						interviewTime: $("#datetimepicker").val()
					},
					dataType: 'json',
					success: function(data) {
						alert("添加成功，请珍惜每一次面试机会！单击刷新页面");
						window.location.reload();
					},
					error: function() {
						alert("添加成功，刷新试试");
					}
				});
			}
		</script>
	</body>

</html>